package org.jeecg.modules.product.test;//package org.jeecg.modules.product.test;
//
//import io.swagger.v3.oas.annotations.tags.Tag;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.core.io.InputStreamResource;
//import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * @Description: Poi-tl 渲染数据并生成 Word 文档
// * @Author: jeecg-boot
// * @Date:   2024-11-14
// * @Version: V1.0
// */
//@Tag(name="Poi-tl 渲染数据并生成 Word 文档")
//@RestController
//@RequestMapping("/Poitl")
//@Slf4j
//public class PoitlController {
//    @Autowired
//    private WordGeneratorService wordGeneratorService;
//
//    @GetMapping("/generate")
//    public ResponseEntity<InputStreamResource> generateWordDocument(String bucketName,String templateObjectName) throws Exception {
//        // 准备数据
//        Map<String, Object> data = new HashMap<>();
//        data.put("id", "100999000");
//        data.put("name", "张三");
//        data.put("date", "2023-11-15");
//        data.put("age", "10000");
//
//        // 模板在MinIO中的对象名称
//        //String templateObjectName = "修改报告模板demo_1748227511066.doc";
//
//        // 输出文件路径
//        String outputPath = "output.docx";
//
//        // 生成文档
//        wordGeneratorService.generateWordDocumentFromMinio(bucketName,templateObjectName, outputPath, data);
//
//        // 返回文件
//        File file = new File(outputPath);
//        InputStreamResource resource = new InputStreamResource(new FileInputStream(file));
//
//        return ResponseEntity.ok()
//                .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + file.getName())
//                .contentType(MediaType.parseMediaType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"))
//                .contentLength(file.length())
//                .body(resource);
//    }
//}
